package com.zimmur.app.mocolink.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zimmur.app.mocolink.domain.model.BackgroundImage;
import com.zimmur.app.mocolink.domain.util.PageUtil;
import com.zimmur.app.mocolink.domain.vo.BannerInfo;
import com.zimmur.app.mocolink.domain.vo.GroupGoodsInfo;
import com.zimmur.app.mocolink.domain.vo.TopicInfo;
import com.zimmur.app.mocolink.service.IBackgroundImageService;
import com.zimmur.app.mocolink.service.IBannerService;
import com.zimmur.app.mocolink.service.IGroupGoodsService;
import com.zimmur.app.mocolink.service.IHomeService;
import com.zimmur.app.mocolink.service.ITopicService;

@Service
public class HomeServiceImpl implements IHomeService {

	@Autowired
	private IBackgroundImageService backgroundImageService;
	@Autowired
	private IBannerService bannerService;
	@Autowired
	private IGroupGoodsService groupGoodsService;
	@Autowired
	private ITopicService topicService;
	private static final int buyIndex=1;
	private static final int findIndex=2;
	@Override
	public Map<String, Object> buyIndex(int userId) {
		Map<String, Object> map=new HashMap<>();
		List<BackgroundImage> imageList=backgroundImageService.selectByType(buyIndex);
		List<BannerInfo> bannerInfos=bannerService.selectByShowMethod(buyIndex);
		PageUtil<GroupGoodsInfo> goodsInfos = groupGoodsService.queryIndexGroupGoods(1, userId);
		map.put("backgroundImageList", imageList);
		map.put("bannerList", bannerInfos);
		map.put("groupGoodsPage",goodsInfos);
		return map;
	}

	@Override
	public Map<String, Object> findIndex(int userId) {
		Map<String, Object> map=new HashMap<>();
		List<BackgroundImage> imageList=backgroundImageService.selectByType(findIndex);
		List<BannerInfo> bannerInfos=bannerService.selectByShowMethod(findIndex);
		PageUtil<TopicInfo> topicInfos=topicService.queryTopicInfo(1);
		map.put("backgroundImageList", imageList);
		map.put("bannerList", bannerInfos);
		map.put("topicPage", topicInfos);
		return map;
	}

}
